/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import data.CompressionGraphData;
import java.util.Vector;

import data.ConfigurationGraphData;
import data.GraphData;
import data.MirroringGraphData;
import gui.OutputTabs;
import gui.SectionChooser;
import gui.graphs3d.ConfigurationGraph;
import gui.graphs3d.MirroringGraph;
import gui.graphs3d.ThinProvisioningGraph;

/**
 *
 * @author HADAR
 */
class ToGuiFacade {
 
//    private TxtOutput _txtOutput;
	private OutputTabs _tabs;
    private ToEngineFacade _toEngineFacade;

    public ToGuiFacade(OutputTabs tabs) {
    	_tabs = tabs;
    }

    public void set_toEngineFacade(ToEngineFacade toEngineFacade) {
        //TODO - this is very ugly, should it be here?
    	_tabs.setToEngineFacade(toEngineFacade);
        _toEngineFacade = toEngineFacade;
    }

    void showClusteringGraph(GraphData gData) {
        _tabs.displayTxt(gData.toString());
        _tabs.setVisible(true);
    }

    void showCompressionGraph(final GraphData gData) {
    	_tabs.displayTxt(gData.toString());
    	_tabs.setVisible(true);
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                CompressionGraphData tData = (CompressionGraphData) gData;
                _tabs.addGraphOutput(new ThinProvisioningGraph(tData));
            }
        });
    }

    void showConfigurationGraph(final GraphData gData) {
        //_txtOutput.
    	_tabs.displayTxt(gData.toString());
    	_tabs.setVisible(true);
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                ConfigurationGraphData tData = (ConfigurationGraphData) gData;
                if (tData.get_ppp().size()>0) {
                	_tabs.addGraphOutput(new ConfigurationGraph(tData));
                }
                else _tabs.removeGraphInput();
            }
        });

    }

    void showMirroringGraph(final GraphData gData) {
        _tabs.displayTxt(gData.toString());
        _tabs.setVisible(true);

        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
            	MirroringGraphData mData = (MirroringGraphData)gData;
            	if (! mData.isEmpty()){
            		//new MirroringGraph(gData, _toEngineFacade).setVisible(true);
            		_tabs.addGraphOutput(new MirroringGraph(gData));
            	}
            	else _tabs.removeGraphInput();
            }
        });
    }

    public void askForInput(Vector<String> data) {
        new SectionChooser(data, _toEngineFacade).setVisible(true);
    }
}
